package cn.iocoder.yudao.module.wine.controller.app.supplyorderlog;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.wine.controller.app.supplyorderlog.vo.SupplyOrderLogRespVO;
import cn.iocoder.yudao.module.wine.dal.dataobject.supplyorderlog.SupplyOrderLogDO;
import cn.iocoder.yudao.module.wine.service.supplyorderlog.SupplyOrderLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 供求订单日志")
@RestController
@RequestMapping("/wine/supply-order-log")
@Validated
public class AppSupplyOrderLogController {

    @Resource
    private SupplyOrderLogService supplyOrderLogService;

    @GetMapping("/list")
    @Operation(summary = "订单追溯")
    @PreAuthorize("@ss.hasPermission('wine:supply-order-log:query')")
    public CommonResult<List<SupplyOrderLogRespVO>> getSupplyOrderLogList(@Valid@RequestParam("orderId") Long orderId) {
        List<SupplyOrderLogDO> list = supplyOrderLogService.getSupplyOrderLogList(orderId);
        return success(BeanUtils.toBean(list, SupplyOrderLogRespVO.class));
    }

}
